package com.charger.chargingcable.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.charger.common.annotation.Log;
import com.charger.common.core.controller.BaseController;
import com.charger.common.core.domain.AjaxResult;
import com.charger.common.enums.BusinessType;
import com.charger.chargingcable.domain.Chargingcable;
import com.charger.chargingcable.service.IChargingcableService;
import com.charger.common.utils.poi.ExcelUtil;
import com.charger.common.core.page.TableDataInfo;

/**
 * 充电枪Controller
 * 
 * @author charger1
 * @date 2024-11-26
 */
@RestController
@RequestMapping("/site/chargingcable")
public class ChargingcableController extends BaseController
{
    @Autowired
    private IChargingcableService chargingcableService;

    /**
     * 查询充电枪列表
     */
    @PreAuthorize("@ss.hasPermi('site:chargingcable:list')")
    @GetMapping("/list")
    public TableDataInfo list(Chargingcable chargingcable)
    {
        startPage();
        List<Chargingcable> list = chargingcableService.selectChargingcableList(chargingcable);
        return getDataTable(list);
    }

    /**
     * 导出充电枪列表
     */
    @PreAuthorize("@ss.hasPermi('site:chargingcable:export')")
    @Log(title = "充电枪", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Chargingcable chargingcable)
    {
        List<Chargingcable> list = chargingcableService.selectChargingcableList(chargingcable);
        ExcelUtil<Chargingcable> util = new ExcelUtil<Chargingcable>(Chargingcable.class);
        util.exportExcel(response, list, "充电枪数据");
    }

    /**
     * 获取充电枪详细信息
     */
    @PreAuthorize("@ss.hasPermi('site:chargingcable:query')")
    @GetMapping(value = "/{chargingcableId}")
    public AjaxResult getInfo(@PathVariable("chargingcableId") Long chargingcableId)
    {
        return success(chargingcableService.selectChargingcableByChargingcableId(chargingcableId));
    }

    /**
     * 新增充电枪
     */
    @PreAuthorize("@ss.hasPermi('site:chargingcable:add')")
    @Log(title = "充电枪", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Chargingcable chargingcable)
    {
        return toAjax(chargingcableService.insertChargingcable(chargingcable));
    }

    /**
     * 修改充电枪
     */
    @PreAuthorize("@ss.hasPermi('site:chargingcable:edit')")
    @Log(title = "充电枪", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Chargingcable chargingcable)
    {
        return toAjax(chargingcableService.updateChargingcable(chargingcable));
    }

    /**
     * 删除充电枪
     */
    @PreAuthorize("@ss.hasPermi('site:chargingcable:remove')")
    @Log(title = "充电枪", businessType = BusinessType.DELETE)
	@DeleteMapping("/{chargingcableIds}")
    public AjaxResult remove(@PathVariable Long[] chargingcableIds)
    {
        return toAjax(chargingcableService.deleteChargingcableByChargingcableIds(chargingcableIds));
    }
}
